var changePwdPage = avalon.define({
	$id: "changePwdPage",
	oldPassword: "",
	newPassword: "",
	repassword: "",
	validate: {
		onValidateAll: function(reasons) {
			if(reasons.length) {
				mui.toast(reasons[reasons.length - 1].getMessage());
			} else {
				var form=$("#changePwdForm");
				mui.ajax('/user/changePwd.do', {
					data: form.serialize(),
					dataType: 'json',
					type:'post',
					success: function(data) {
						mui.alert("", data.msg, function(){
							window.localStorage.removeItem("dahua_userId");
							window.localStorage.removeItem("dahua_isPartner");
							var url = "dahua://login";
							mui.openWindow({
								url: url
							});
						});
					}
				});
			}
		}
	},
	changePwd:function(e){
		e.preventDefault()
		this.validate.onManual();
	}
})

